package com.yjkf.zh.admin.controller;
/*
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

/*
pom.xml
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>aliyun-java-sdk-core</artifactId>
  <version>4.0.3</version>
</dependency>
*/
/*
public class SysIotTest{
    public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "LTAI15a7DBp6ScmD", "oLSe0uvSamvGQvMEmN2hAGawdJ4W4g");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.GET);
        request.setSysDomain("iot.cn-shanghai.aliyuncs.com");
        request.setSysVersion("2018-01-20");
        request.setSysAction("BatchCheckDeviceNames");
        request.putQueryParameter("RegionId", "cn-shanghai");
        request.putQueryParameter("ProductKey", "a1UTv0vmM7k");
        request.putQueryParameter("DeviceName.2", "test0001");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}*/
/*import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;


import java.util.List;
import java.util.Map;*/
/*
pom.xml
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>aliyun-java-sdk-core</artifactId>
  <version>4.0.3</version>
</dependency>
*/

/*
//服务调用API
public class SysIotTest {
    public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "LTAI15a7DBp6ScmD", "oLSe0uvSamvGQvMEmN2hAGawdJ4W4g");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.GET);
        request.setSysDomain("iot.cn-shanghai.aliyuncs.com");
        request.setSysVersion("2018-01-20");
        request.setSysAction("GetDeviceStatus");
        request.setSysAction("QueryDevicePropertyStatus");
        request.putQueryParameter("RegionId", "cn-shanghai");
        request.putQueryParameter("ProductKey", "a1UTv0vmM7k");
        request.putQueryParameter("DeviceName", "iot_tc");
        List<Map<Object, Object>> result = null;
        try {

            CommonResponse response = client.getCommonResponse(request);

           // JSONObject jsonObject= new JSONObject();
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}*/

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
/*
pom.xml
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>aliyun-java-sdk-core</artifactId>
  <version>4.0.3</version>
</dependency>
*/
public class SysIotTest {

    public static void main(String[] args) {
        //添加产品API
    /*    DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "LTAI4FteAmT72WrKLJkj5QdV", "O3PxeWvPTHajKwwZ4AS4JlfRSFe98C");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.GET);
        request.setSysDomain("iot.cn-shanghai.aliyuncs.com");
        request.setSysVersion("2018-01-20");
        request.setSysAction("CreateProduct");
        request.putQueryParameter("RegionId", "cn-shanghai");
        request.putQueryParameter("NodeType", "0");
        request.putQueryParameter("ProductName", "my_product01");
        request.putQueryParameter("DataFormat", "0");
        request.putQueryParameter("Description", "API调试");
        request.putQueryParameter("AliyunCommodityCode", "iothub_senior");
        request.putQueryParameter("NetType", "CELLULAR");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response);
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }*/
/*
        //创建设备
        DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "LTAI4FteAmT72WrKLJkj5QdV", "O3PxeWvPTHajKwwZ4AS4JlfRSFe98C");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.GET);
        request.setSysDomain("iot.cn-shanghai.aliyuncs.com");
        request.setSysVersion("2018-01-20");
        request.setSysAction("RegisterDevice");
        request.putQueryParameter("RegionId", "cn-shanghai");
        request.putQueryParameter("ProductKey", "a1CkMYvXD0j");
        request.putQueryParameter("DeviceName", "API_test01");
        request.putQueryParameter("Nickname", "API_test01");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }*/

       /*
        //查看设备详情
       DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "LTAI4FteAmT72WrKLJkj5QdV", "O3PxeWvPTHajKwwZ4AS4JlfRSFe98C");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.GET);
        request.setSysDomain("iot.cn-shanghai.aliyuncs.com");
        request.setSysVersion("2018-01-20");
        request.setSysAction("QueryDeviceDetail");
        request.putQueryParameter("RegionId", "cn-shanghai");
        request.putQueryParameter("ProductKey", "a1CkMYvXD0j");
        request.putQueryParameter("DeviceName", "API_test01");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }*/

            DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "LTAI15a7DBp6ScmD", "oLSe0uvSamvGQvMEmN2hAGawdJ4W4g");
            IAcsClient client = new DefaultAcsClient(profile);

            CommonRequest request = new CommonRequest();
            request.setSysMethod(MethodType.GET);
            request.setSysDomain("iot.cn-shanghai.aliyuncs.com");
            request.setSysVersion("2018-01-20");
            request.setSysAction("InvokeThingService");
            request.putQueryParameter("RegionId", "cn-shanghai");
            request.putQueryParameter("Args", "{\"F_MODBUS_16_YBDI\":01}	");
            request.putQueryParameter("Identifier", "F_MODBUS_16");
            request.putQueryParameter("ProductKey", "a1UTv0vmM7k");
            request.putQueryParameter("DeviceName", "iot_tc");
            try {
                CommonResponse response = client.getCommonResponse(request);
                System.out.println(response.getData());
            } catch (ServerException e) {
                e.printStackTrace();
            } catch (ClientException e) {
                e.printStackTrace();
            }

    }
}
